export default class Color {
  r: number;
  g: number;
  b: number;

  constructor(r: number, g: number, b: number) {
    this.r = r;
    this.g = g;
    this.b = b;
  }

  static black = new Color(0, 0, 0);
  static white = new Color(1, 1, 1);
  static red = new Color(1, 0, 0);
  static green = new Color(0, 1, 0);
  static blue = new Color(0, 0, 1);

  copy(): Color {
    return new Color(this.r, this.g, this.b);
  }

  add(color: Color): Color {
    return new Color(this.r + color.r, this.g + color.g, this.b + color.b);
  }

  multiply(s: number): Color {
    return new Color(this.r * s, this.g * s, this.b * s);
  }

  modulate(color: Color): Color {
    return new Color(this.r * color.r, this.g * color.g, this.b * color.b);
  }

  saturate() {
    this.r = Math.min(this.r, 1);
    this.g = Math.min(this.g, 1);
    this.b = Math.min(this.b, 1);
  }
}